package com.xtkj.accountjava.service.impl;
import com.xtkj.accountjava.entity.AccountBookEntity;
import com.xtkj.accountjava.entity.UserAccountBookEntity;
import com.xtkj.accountjava.mapper.AccountBookMapper;
import com.xtkj.accountjava.mapper.UserAccountBookMapper;
import com.xtkj.accountjava.service.UserAccountBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserAccountBookServiceImpl implements UserAccountBookService {
    @Autowired
    UserAccountBookMapper userAccountBookMapper;

    @Autowired
    AccountBookMapper accountBookMapper;


    @Override
    public UserAccountBookEntity findOnlyUserAccountBooksById(int id) {
        return userAccountBookMapper.selectById(id);
    }

    @Override
    public UserAccountBookEntity findUserAccountBooksCategorysById(int id) {
        UserAccountBookEntity userAccountBookEntity = userAccountBookMapper.selectById(id);
        Long accountBookId = userAccountBookEntity.getAccountBookId();
        AccountBookEntity accountBookEntity = accountBookMapper.findAccountBookAndCategorysById(accountBookId.intValue());
        userAccountBookEntity.setAccountBookEntity(accountBookEntity);

        return userAccountBookEntity;
    }
}
